package com.kmxd.ams.core.common.enums;

import com.kmxd.ams.core.common.constant.ErrorCode;
import com.kmxd.ams.core.exception.BizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 拆离类型
 *
 * @author nickbi
 */
@Getter
@AllArgsConstructor
public enum DetachEnum {

  /** 案卷 */
  VOLUME(1, "案卷"),
  /** 盒 */
  BOX(2, "盒"),
  /** 项目 */
  PROJ(3, "项目");

  private Integer type;
  private String desc;

  public static DetachEnum convert(Integer type) {
    return Arrays.stream(values())
        .filter(x -> x.type.equals(type))
        .findAny()
        .orElseThrow(() -> BizException.instance(ErrorCode.NOT_FOUND, "未找到拆离状态：" + type));
  }
}
